import 'package:base/main.dart';
import 'package:flutter/material.dart';
import 'package:module_discover/pages/filter_domain/filter_domain_logic.dart';
import 'package:module_discover/pages/filter_domain/widgets/domain_content/domain_content_item_widget.dart';

class DomainContentWidget extends StatelessWidget {
  final FilterDomainLogic logic;

  const DomainContentWidget({super.key, required this.logic});

  @override
  Widget build(BuildContext context) {
    return Obx(() {
      if (logic.domainTitles.isEmpty) {
        return Center(child: CircularProgressIndicator());
      }
      String parentKey =
          logic.domainTitles[logic.selectedIndex.value].value.key;
      String name = logic.domainTitles[logic.selectedIndex.value].value.name;
      Log.i("右边子组件,$name ; $parentKey");
      return Container(
        color: Colors.white,
        child: Column(
          children: [
            Expanded(
              child: ListView.builder(
                  padding: EdgeInsets.all(8),
                  itemCount: logic
                      .filterStateVM.childCategories[parentKey]?.value.length,
                  itemBuilder: (context, index) => ContentItemWidget(
                        parentKey: parentKey,
                        child: logic.filterStateVM.childCategories[parentKey]
                            ?.value[index],
                      )),
            ),
          ],
        ),
      );
    });
  }
}
